<% @page_title = "Admins" %>

<div class="page-header">
  <h2>Your Registration</h2>
</div>

<div class="Admin list">
  <%= link_to('Manage Account', edit_admin_registration_path(current_admin), class: 'btn btn-default') %>
  <h2>Users</h2>

  <% if params[:approved] == "false" %>
      <%= link_to "All Admins", :action => "list" %>
  <% else %>
      <%= link_to "Admins awaiting approval", :action => "list", :approved => "false" %>
  <% end %>

  <div><%= pluralize(@admins.size, 'admin') %> found</div>
  <table class="table table-condensed table-hover">
    <thead>
      <tr>
        <th>&nbsp;</th>
        <th>Name</th>
        <th>Username</th>
        <th>Actions</th>
      </tr>
    </thead>
    <tbody>
    <% @admins.each do |admin| %>
      <tr>
        <td><%= image_tag('administrator.png', size: '35x35') %></td>
        <td><%= admin.name %></td>
        <td><%= admin.username %></td>
        <td class="actions">
          <% if admin.approved? %>
              <%= link_to "Revoke", revoke_admin_path(admin), method: :post, class: 'btn btn-default btn-xs' %>
          <% else %>
              <%= link_to "Approve", approve_admin_path(admin), method: :post, class: 'btn btn-default btn-xs' %>
          <% end %>
          <%=  link_to "Logins", logins_admin_path(admin), class: 'btn btn-default btn-xs' %>
          <%= link_to "Delete", admin_path(admin), method: :delete, data: {confirm: 'Are you sure you want to permanently delete this admin?'}, class: 'btn btn-default btn-xs' %>
        </td>
      </tr>
    <% end %>
    </tbody>
  </table>
</div>